﻿using System;
using System.Globalization;
namespace RapidRepository
{
    /// <summary>
    /// Design by contract assertions.
    /// </summary>
    internal static class Contract
    {
        /// <summary>
        /// Throws an exception if the passed in assertion fails.
        /// </summary>
        /// <param name="parameterName">Name of the parameter.</param>
        /// <param name="assertion">if set to <c>true</c> [assertion].</param>
        public static void Requires(string parameterName, bool assertion)
        {
            if (!assertion)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "{0} failed a contract assertion.", parameterName));
            }
        }
    }
}
